<?php
defined("_VALID_ACCESS") || die('Direct access forbidden');
class SCTV_PaymentCommon extends ModuleCommon {
 
    public static function menu() {
    	return array(__('SCTV') => array(
    		'__submenu__' => 1, __('Payment') => array()
		));
    }
	public static function process_request($data, $mode) {
        switch($mode) {        	
        	case 'adding':				
                break;
			case 'added':
				$rec = Utils_RecordBrowserCommon::get_records('SCTV_Payment', array('>id'=>$data['id']), array('remaining'), array('id'=>'DESC'), array('numrows'=>1));
				$remaining = 0;
				if($rec != null)
					 $remaining = $rec[0]['remaining'] - $data['money'];							
				Utils_RecordBrowserCommon::update_record('SCTV_Payment',$data['id'],array('date_time'=>date('Y-m-d H:i:s'), 'remaining'=>$remaining));
				
				
				break;
            default:
                break;
        }
        return $data;
    }
	public static function display_money($record, $nolink, $desc) {	
		$money = $record[$desc['id']];		
		return Utils_CurrencyFieldCommon::format($money);		
	}
	public static function router($id)
	{
		$a = Utils_RecordBrowserCommon::get_record_href_array('SCTV_Payment', $id);
		$a = Module::create_href_js($a);
		return $a;
	}
}
 
?>